<template>
	<view class="">
		<uni-loading v-if="loading"></uni-loading>
		<view class="body" v-else>
			<view class="top-container no-bottom-padding">
				<uni-list :border="false">
					<uni-list-item :border="false" title="执行者" :rightText="userInfo.name" />
					<uni-list-item :border="false" title="生产任务单编号" v-if="billNo" :rightText="billNo" />
					<uni-list-item :border="false" :showArrow="!billNo" title="生产车间"
						:rightText="produceHouseName || '请选择生产车间'" :clickable="!billNo"
						@click="handleChooseDepartment('department')" />
					<uni-list-item v-if="type === 'edit'" :border="false" showArrow title="供应商批次"
						:rightText="supplierBatchNo || '请输入供应商批次'" clickable @click="bindInputBatchNo('supplier')" />
					<uni-list-item v-if="!billNo" :border="false" :showArrow="!billNo" title="紧急程度">
						<template v-slot:footer>
							<picker @change="bindPickerChange" :value="sortIndex" :range="sortList">
								<view class="picker">{{sortList[sortIndex] || '0'}}</view>
							</picker>
						</template>
					</uni-list-item>
					<uni-list-item v-else :border="false" title="紧急程度"
						:rightText="header.sort ? header.sort.toString() : '0'" />
					<uni-list-item :border="false" title="计划开工时间">
						<template v-slot:footer>
							<uni-dateformat v-if="startTime" :date="startTime" format="yyyy年MM月dd日 hh:mm:ss">
							</uni-dateformat>
						</template>
					</uni-list-item>
					<uni-list-item :border="false" :showArrow="!billNo" title="计划完工时间">
						<template v-slot:footer>
							<uni-datetime-picker v-model="endTime" :disabled="billNo !== ''">
								<uni-dateformat v-if="endTime" :date="endTime" format="yyyy年MM月dd日 hh:mm:ss">
								</uni-dateformat>
							</uni-datetime-picker>
						</template>
					</uni-list-item>
					<uni-list-item :border="false" title="生产日期">
						<template v-slot:footer >
							<uni-datetime-picker  v-model="produceDate" :disabled="billNo == ''">
								<uni-dateformat  v-if="produceDate" :date="produceDate" format="yyyy年MM月dd日 hh:mm:ss">
								</uni-dateformat>
							</uni-datetime-picker>
						</template>
					</uni-list-item>
					<uni-list-item :border="false" title="已领重量"
						:rightText="header.pickedCount ? header.pickedCount.toString() : '0'" />
					<uni-list-item v-if="type === 'edit'" :border="false" showArrow title="所有批次"
						:rightText="batchNo || '请输入批次'" clickable @click="bindInputBatchNo('batch')" />
				</uni-list>
			</view>
			<!--  列表  -->
			<template v-if="taskList && taskList.length > 0">
				<template v-if="type === 'edit'">
					<view class="list-pagination">
						<view class="list-pagination-inner">
							<view class="item-sticky">
								<view class="title">已扫追溯码个数</view>
								<view class="extra">{{traceBackCount}}</view>
							</view>
							<view class="item-sticky">
								<view class="title">当前用户已扫追溯码</view>
								<view class="extra">{{userCount || 0}}</view>
							</view>
							<view class="pagination">
								<uni-pagination :total="total" :pageSize="size" v-model="current"
									@pageTo="bindInputBatchNo('page')" />
							</view>
						</view>
					</view>
					<view class="" v-for="(item, index) in pageList" :key="index">
						<view class="panel">
							<view class="panel_title">
								<view class="panel_title_left">{{ item.materialName }}</view>
							</view>
							<view class="panel_content">
								<view class="panel_content_row">
									<view class="panel_content_row_item">
										<view class="panel_content_row_item_title">物料编码：</view>
										<view class="panel_content_row_item_value">{{ item.materialNo }}</view>
									</view>
									<view class="panel_content_row_item">
										<view class="panel_content_row_item_title">规格：</view>
										<view class="panel_content_row_item_value">{{ item.materialModel }}</view>
									</view>
								</view>
								<view class="panel_content_row">
									<view class="panel_content_row_item">
										<view class="panel_content_row_item_title">单位：</view>
										<view class="panel_content_row_item_value">{{ item.unitName }}</view>
									</view>
									<!-- 完成的时候，这里显示绑定追溯码的数量 -->
									<template v-if="type === 'edit'">
										<view class="panel_content_row_item">
											<view class="panel_content_row_item_title">收货数量：</view>
											<view class="panel_content_row_item_value">
												<view class="panel_content_row_item_value_input"
													v-if="!item.currentCount">
													<input type="digit" v-model="item.count" placeholder="请输入收货数量"
														placeholder-class="input-placeholder"
														@input="handleAddBounce(item)" />
												</view>
												<span v-else>{{ Number(item.count).toFixed(1) }}</span>
											</view>
										</view>
									</template>
									<!-- 保持之前的逻辑不变 -->
									<template v-else>
										<view class="panel_content_row_item">
											<view class="panel_content_row_item_title">数量：</view>
											<view class="panel_content_row_item_value">
												<view class="panel_content_row_item_value_input" v-if="!billNo">
													<input type="digit" v-model="item.count" placeholder="请输入数量"
														placeholder-class="input-placeholder" />
												</view>
												<span v-else>{{ item.count }}</span>
											</view>
										</view>
									</template>
								</view>
								<view class="panel_content_row" v-if="type === 'inStock'">
									<view class="panel_content_row_item w-full">
										<view class="panel_content_row_item_title">已入库数量：</view>
										<view class="panel_content_row_item_value padding-r">
											<span>{{ item.prdInCount || 0 }}</span>
										</view>
									</view>
								</view>
								<view class="panel_content_row" v-if="item.insertUserName">
									<view class="panel_content_row_item w-full">
										<view class="panel_content_row_item_title">创建人：</view>
										<view class="panel_content_row_item_value">
											<span>{{ item.insertUserName }}</span>
										</view>
										<view class="panel_content_row_item" v-if="handleIsComplete(item)">
											<view class="panel_content_row_item_title">追溯重量：</view>
											<view class="panel_content_row_item_value" style="padding-right: 20rpx;">
												<view class="panel_content_row_item_value_input">
													<input type="digit" v-model="item.traceCount" placeholder="请输入追溯重量"
														@input="handleAddBounce(item)" />
												</view>
											</view>
										</view>
									</view>
								</view>
								<view class="panel_content_row" v-if="type === 'edit' || item.batchNo">
									<view class="panel_content_row_item w-full">
										<view class="panel_content_row_item_title">批次：</view>
										<view class="panel_content_row_item_value">
											<view class="panel_content_row_item_value_input flex-1"
												v-if="type === 'edit'">
												<input @input="handleFocus(item,$event)" type="text"
													v-model="item.batchNo" placeholder="请输入批次(必填)"
													placeholder-class="input-placeholder" />
											</view>
											<span v-else>{{ item.batchNo }}</span>
										</view>
									</view>
								</view>
								<template v-if="type === 'edit'">
									<view class="panel_content_row" v-if="handleIsComplete(item)">
										<view class="panel_content_row_item">
											<view class="panel_content_row_item_title">标准：</view>
											<view class="panel_content_row_item_value" style="padding-right: 20rpx;">
												<view class="panel_content_row_item_value_input">
													<input type="digit" v-model="item.standard" placeholder="请输入标准数量"
														placeholder-class="input-placeholder"
														@input="handleAddBounce(item)" />
												</view>
											</view>
										</view>
										<view class="panel_content_row_item">
											<view class="panel_content_row_item_title">已扫数量：</view>
											<view class="panel_content_row_item_value">
												<span>{{ item.currentCount }}</span>
											</view>
										</view>
									</view>
									<view class="panel_content_row">
										<view class="panel_content_row_item w-full align-items-start"
											v-if="item.traceBack && item.traceBack.length">
											<view class="panel_content_row_item_title">追溯码：</view>
											<view class="panel_content_row_item_value padding-r trace-back">
												<view class="trace-back-item" v-for="(trace, traceI) in item.traceBack">
													<view>{{ handleTrace(trace)}}</view>
													<view @click="handleTraceDelete(item, traceI)">
														<i class="iconfont icon-shanchu"></i>
													</view>
												</view>
											</view>
										</view>
									</view>
								</template>
								<view class="flex-list-btn" v-if="type === 'edit'">
									<view v-if="item.isDelete" class="flex-list-btn-item"
										@click.stop="handleTemporaryDelete(item.id)">
										删除
									</view>
									<view v-if="!item.noPrint" class="flex-list-btn-item"
										@click.stop="handleCancelPrintModal(item.id)">
										取消打印
									</view>
									<view v-if="handleIsComplete(item)" class="flex-list-btn-item"
										@click.stop="handleScanning(item, index)">
										追溯扫码
									</view>
									<view class="flex-list-btn-item" @click.stop="handleTemporaryAdd(item, index)">
										增加
									</view>
								</view>
							</view>
						</view>
					</view>
				</template>
				<uni-swipe-action v-else>
					<uni-swipe-action-item :left-options="options" v-for="(item, index) in taskList"
						:disabled="billNo !== ''" @click="handleDelete(index)" v-if="index < 20">
						<view class="panel">
							<view class="panel_title">
								<view class="panel_title_left">{{ item.materialName }}</view>
							</view>
							<view class="panel_content">
								<view class="panel_content_row">
									<view class="panel_content_row_item">
										<view class="panel_content_row_item_title">物料编码：</view>
										<view class="panel_content_row_item_value">{{ item.materialNo }}</view>
									</view>
									<view class="panel_content_row_item">
										<view class="panel_content_row_item_title">规格：</view>
										<view class="panel_content_row_item_value">{{ item.materialModel }}</view>
									</view>
								</view>
								<view class="panel_content_row">
									<view class="panel_content_row_item">
										<view class="panel_content_row_item_title">单位：</view>
										<view class="panel_content_row_item_value">{{ item.unitName }}</view>
									</view>
									<!-- 完成的时候，这里显示绑定追溯码的数量 -->
									<template v-if="type === 'edit'">
										<view class="panel_content_row_item">
											<view class="panel_content_row_item_title">收货数量：</view>
											<view class="panel_content_row_item_value">
												<view class="panel_content_row_item_value_input"
													v-if="!item.currentCount">
													<input type="digit" v-model="item.count" placeholder="请输入收货数量"
														placeholder-class="input-placeholder"
														@input="handleAddBounce(item)" />
												</view>
												<span v-else>{{ item.count }}</span>
											</view>
										</view>
									</template>
									<!-- 保持之前的逻辑不变 -->
									<template v-else>
										<view class="panel_content_row_item">
											<view class="panel_content_row_item_title">数量：</view>
											<view class="panel_content_row_item_value">
												<view class="panel_content_row_item_value_input" v-if="!billNo">
													<input type="digit" v-model="item.count" placeholder="请输入数量"
														placeholder-class="input-placeholder" />
												</view>
												<span v-else>{{ item.count }}</span>
											</view>
										</view>
									</template>
								</view>
								<view class="panel_content_row" v-if="type === 'inStock'">
									<view class="panel_content_row_item w-full">
										<view class="panel_content_row_item_title">已入库数量：</view>
										<view class="panel_content_row_item_value padding-r">
											<span>{{ item.prdInCount || 0 }}</span>
										</view>
									</view>
								</view>
								<view class="panel_content_row" v-if="type === 'edit' || item.batchNo">
									<view class="panel_content_row_item w-full">
										<view class="panel_content_row_item_title">批次：</view>
										<view class="panel_content_row_item_value">
											<view class="panel_content_row_item_value_input flex-1"
												v-if="type === 'edit'">
												<input @input="handleFocus(item,$event)" type="text"
													v-model="item.batchNo" placeholder="请输入批次(必填)"
													placeholder-class="input-placeholder" />
											</view>
											<span v-else>{{ item.batchNo }}</span>
										</view>
									</view>
								</view>
								<template v-if="type === 'edit'">
									<view class="panel_content_row" v-if="handleIsComplete(item)">
										<view class="panel_content_row_item">
											<view class="panel_content_row_item_title">标准：</view>
											<view class="panel_content_row_item_value" style="padding-right: 20rpx;">
												<view class="panel_content_row_item_value_input">
													<input type="digit" v-model="item.standard" placeholder="请输入标准数量"
														placeholder-class="input-placeholder"
														@input="handleAddBounce(item)" />
												</view>
											</view>
										</view>
										<view class="panel_content_row_item">
											<view class="panel_content_row_item_title">已扫数量：</view>
											<view class="panel_content_row_item_value">
												<span>{{ item.currentCount }}</span>
											</view>
										</view>
									</view>
									<view class="panel_content_row">
										<view class="panel_content_row_item w-full align-items-start"
											v-if="item.traceBack && item.traceBack.length">
											<view class="panel_content_row_item_title">追溯码：</view>
											<view class="panel_content_row_item_value padding-r trace-back">
												<view class="trace-back-item" v-for="(trace, traceI) in item.traceBack">
													<view>{{ handleTrace(trace)}}</view>
													<view @click="handleTraceDelete(item, traceI)">
														<i class="iconfont icon-shanchu"></i>
													</view>
												</view>
											</view>
										</view>
									</view>
								</template>
								<view class="flex-list-btn" v-if="type === 'edit'">
									<view v-if="item.isDelete" class="flex-list-btn-item"
										@click.stop="handleTemporaryDelete(item.id)">
										删除
									</view>
									<view v-if="!item.noPrint" class="flex-list-btn-item"
										@click.stop="handleCancelPrintModal(item.id)">
										取消打印
									</view>
									<view v-if="handleIsComplete(item)" class="flex-list-btn-item"
										@click.stop="handleScanning(item, index)">
										追溯扫码
									</view>
									<view class="flex-list-btn-item" @click.stop="handleTemporaryAdd(item, index)">
										增加
									</view>
								</view>
							</view>
						</view>
					</uni-swipe-action-item>
				</uni-swipe-action>
			</template>
			<uni-empty-info v-else label="暂无任务信息" :top="50"></uni-empty-info>

			<!--  底部按钮  -->
			<view class="footerPanel">
				<view class="footerPanel_body">
					<template v-if="type !== 'edit'">
						<button v-if="!billNo && type === 'create'" @click="handleChooseDepartment('material')"
							class="footerBtn reset"><i class="iconfont icon-duihao btn_icon"></i>选择
						</button>

						<template v-if="judgeAuthority(['sysadmin'])">
							<button v-if="billNo && type === 'create' && header.status === 'save'"
								@click="handleWarehousing" class="footerBtn save"
								:class="{onlyBtn: billNo && taskType === 'sorting'}"><i
									class="iconfont icon-shenhe btn_icon"></i>审核
							</button>
						</template>
						<template v-if="!billNo">
							<button @click="handleGenerateListing" class="footerBtn scan" type="primary"><i
									class="iconfont icon-shengchenggongdan btn_icon"></i>生成物料清单
							</button>
						</template>
						<template v-else>
							<button v-if="type === 'get' || type === 'fill'" @click="handleWatchCreatedOrder"
								class="footerBtn save">
								<i class="iconfont icon-renwu btn_icon"></i>已创建订单
							</button>
							<button @click="handleWatchGenerateListing" class="footerBtn scan" type="primary"><i
									class="iconfont icon-shengchenggongdan btn_icon"></i>查看物料清单
							</button>
						</template>
					</template>
					<template v-else>
						<button @click="handleChooseDepartment('material')" class="footerBtn reset"><i
								class="iconfont icon-duihao btn_icon"></i>选择
						</button>
						<button :disabled="!bat || btnLoading" @click="savePrdTaskToPrdCol()" type="primary"
							class="footerBtn scan onlyBtn loading-btn">
							<span class="btn_icon icon-rotation" v-if="btnLoading">
								<uni-icons type="spinner-cycle" color="#ffffff" size="20"></uni-icons>
							</span>
							<i class="iconfont icon-duihao btn_icon" v-else></i>
							完成任务
						</button>
					</template>
				</view>
			</view>

			<!-- 级联选择 -->
			<CascadePicker class="picker-view" ref="pickerView" :popupTitle="popupInfo[currentType].popupTitle"
				:map="currentType === 'material' ? {text:'materialName',value:'materialNo'} : {text:'fName',value:'fNumber'}"
				@change="onchange" @datachange="ondatachange" @nodeclick="onnodeclick" @search="handleSearch"
				@scrolltolower="handleScrolltolower" @refresherrefresh="onRefresh" :triggered="triggered"
				:loading="pickerLoading" :searchPlaceholder="popupInfo[currentType].searchPlaceholder"
				:bottomLoading="pickerPageConfig.pageLoading" :end="pickerPageConfig.pageEnd">
			</CascadePicker>

			<!-- 弹出层 -->
			<ScaningPopup ref="scaningPopup" :isLocation="false" title="领料出库" type="picking" @success="initData">
			</ScaningPopup>

			<uni-popup ref="batchPopup">
				<view class="batchPopup-panel">
					<view class="batchPopup-panel-top">
						<view class="batchPopup-panel-top-title">
							{{batchPopup.title}}
						</view>
						<view class="batchPopup-panel-close">
							<i class="iconfont "></i>
						</view>
					</view>
					<view class="batchPopup-panel-content">
						<view class="batchPopup-panel-content-input">
							<input type="text" v-if="inputType === 'batch'" v-model="batchNo" placeholder="请输入批次" />
							<input type="text" v-else-if="inputType === 'supplier'" v-model="supplierBatchNoTem"
								placeholder="请输入供应商批次" />
							<input type="text" v-else-if="inputType === 'page'" v-model="currentPage"
								placeholder="请输入跳转页数" />
						</view>
					</view>
					<view class="batchPopup-panel-footer">
						<button @click="bindApplyBatchNo()" type="primary"
							class="batchPopup-panel-footer-btn loading-btn" :disabled="btnLoading">
							<span class="btn_icon icon-rotation" v-if="btnLoading">
								<uni-icons type="spinner-cycle" color="#ffffff" size="20"></uni-icons>
							</span>
							{{batchPopup.confirm}}
						</button>
					</view>
				</view>
			</uni-popup>

			<!-- 弹出层 -->
			<WholePopup ref="wholePopup" title="追溯扫码" :autoClose="false" @confirm="addQueue">
			</WholePopup>
			<!--  操作面板  -->
			<min-action-sheet ref="as"></min-action-sheet>
		</view>
	</view>
</template>
<script>
	import dayjs from 'dayjs'
	import uniLoading from "../../vBase/components/uni-loading/uni-loading"
	import uniEmptyInfo from "../../vBase/components/uni-empty-info/uni-empty-info"
	import ScaningPopup from "@/components/popup/materialPopup.vue"
	import CascadePicker from '../../components/cascade-picker/cascade-picker-view.vue'
	import CascadePickerJs from '../../components/cascade-picker/cascade-picker.js'
	import WholePopup from "@/components/popup/wholePopup"

	export default {
		components: {
			uniLoading,
			uniEmptyInfo,
			WholePopup,
			CascadePicker,
			ScaningPopup
		},
		mixins: [CascadePickerJs],
		data() {
			return {
				taskType: '',
				type: 'create',
				billNo: '',
				loading: true,
				taskList: [],
				options: [{
					text: '删除',
					style: {
						backgroundColor: '#FF4E74'
					}
				}],
				currentType: 'material',
				departmentList: [],
				materialList: [],
				keyword: null,
				pickerPageConfig: {
					pageIndex: 0,
					pageSize: 20,
					pageEnd: false,
					pageLoading: true
				},
				triggered: false,
				startTime: dayjs().$d.format('yyyy-MM-dd hh:mm:ss'),
				endTime: dayjs().add(1, 'day').$d.format('yyyy-MM-dd hh:mm:ss'),
				produceDate: null,//生产日期
				produceHouse: "",
				produceHouseName: "", // 生产车间名称
				supplierBatchNo: "", // 供应商名称
				supplierBatchNoTem: "", // 供应商名称
				header: {},
				userCount: 0,
				pickerLoading: true, // 组件加载
				popupInfo: {
					material: {
						searchPlaceholder: '请输入物料编码或名称',
						popupTitle: "选择物料",
					},
					department: {
						searchPlaceholder: '请输入车间编码名称',
						popupTitle: "选择车间",
					}
				},
				sortList: ['0', '1', '2', '3', '4', '5'],
				sortIndex: 0,
				batchNo: '', // 批次
				inputType: "", // 输入框类型（batch：批次，supplier：供应商）
				scanIndex: 0, // 当前扫码index
				bat: false,
				requestStatus: false,
				time: null,
				btnLoading: false,
				operator: "",

				// 完成任务分页
				current: 1, // 当前页
				total: 0, // 总页数
				size: 20, // 每页数据
				currentPage: null,

				batchPopup: {
					title: "",
					confirm: ""
				},

				queueList: [], // 队列
				isExecution: false, // 是否执行中
				currentBox: null
			}
		},
		onShow() {
			
			if (this.billNo) {
				// 获取详情数据
				this.initData()
			}
		},
		onLoad(e) {
			
			if (e.taskType) {
				this.taskType = e.taskType
				this.popupInfo.material.popupTitle = this.taskType === 'sorting' ? '分选' : '半成品、产成品'
			}
			if (e.type) this.type = e.type
			if (e.billNo) {
				this.billNo = e.billNo
				// 获取详情数据
				this.initData()
			} else {
				this.loading = false
			}
		},
		watch: {
			currentType(val) {
				this.keyword = null
			},
			userInfo() {
				if (this.userInfo?.department && this.userInfo?.departmentName) {
					this.produceHouse = this.userInfo.department
					this.produceHouseName = this.userInfo.departmentName
				}
			},
			current() {
				this.$nextTick(() => {
					uni.pageScrollTo({
						scrollTop: 402,
						duration: 50
					});
				})
			}
		},
		mounted() {},
		computed: {
			traceBackCount() {
				return this.taskList.reduce((pre, cur) => {
					if (cur.traceBack && cur.traceBack.length) pre += cur.traceBack.length
					return pre
				}, 0)
			},
			pageList() {
				return this.taskList.slice((this.current - 1) * this.size, (this.current) * this.size)
			}
		},
		methods: {
			/**
			 * 判断批次是否全部填写
			 */
			handleAllBatchNoCheck() {
				let index = this.taskList.findIndex(v => {
					return !v.batchNo
				})
				this.bat = index === -1
			},

			/**
			 * 填写批次
			 * @param {Object} item
			 * @param {Object} e
			 */
			handleFocus(item, e) {
				this.handleAddBounce(item)
			},
			/** 初始化 */
			async initData() {
				if (this.requestStatus) {
					return
				}
				this.requestStatus = true
				// 如果是完成任务
				if (this.type === 'edit') {
					await this.getSaveTaskPrdColList()
				}
				this.getDataDetail()
				this.loading = false
			},

			/**
			 * 页数超出处理
			 */
			hanldeMathPage() {
				let num = Math.ceil(this.total / this.size)
				// 当前页数大于最大页数
				if (this.current > num) this.current = num
				if (this.current < 1) this.current = 1
			},

			/**
			 * 完成任务获取临时收货列表
			 */
			async getSaveTaskPrdColList() {
				try {
					this.btnLoading = true
					const res = await this.$api.saveTaskGetPrdColList({
						billNo: this.billNo
					})
					this.taskList = res.data ?? []
					for (var i = 0; i < this.taskList.length; i++) {

						if (this.taskList[i].traceCount === 0) {
							this.taskList[i].traceCount = 1
						}
					}

					this.total = this.taskList?.length ?? 0

					// 本地更新当前用户已扫码数量(避免每次都调用接口获取当前用户已扫数量)
					// this.userCount = this.taskList.filter(v => v.insertUserName === this.userInfo.name).reduce((pre,
					// 	cur) => {
					// 	pre += cur.currentCount
					// 	return pre
					// }, 0)

					this.hanldeMathPage()
					this.handleAllBatchNoCheck()
				} finally {
					this.btnLoading = false
				}
			},

			/**
			 * 删除临时收货列表数据
			 * 
			 * @param {Object} id
			 */
			async handleTemporaryDelete(id) {
				let self = this
				uni.showModal({
					title: "提示",
					content: "是否确定删除",
					success: () => {
						self.saveTaskDeletePrdCol(id)
					}
				})
			},

			/**
			 * 删除
			 */
			async saveTaskDeletePrdCol(id) {
				try {
					const res = await this.$api.saveTaskDeletePrdCol({
						id: id
					})
					if (!res.res) return
					// 刷新列表数据
					this.getSaveTaskPrdColList()
				} finally {}
			},

			/**
			 * 取消打印
			 * @param {Object} id
			 */
			handleCancelPrintModal(id) {
				let self = this
				uni.showModal({
					title: "提示",
					content: "是否取消打印",
					success: (result) => {
						if (result.confirm) {
							self.handleCancelPrint(id)
						}
					}
				})
			},

			/**
			 * 确认取消打印
			 * @param {Object} id
			 */
			async handleCancelPrint(id) {
				const res = await this.$api.saveTaskNoPrint({
					id: id
				})
				if (!res.res) return
				// 刷新列表数据
				this.getSaveTaskPrdColList()
			},

			/**
			 * 修改物料信息
			 */
			handleAddBounce(e) {
				if (this.time !== null) {
					clearTimeout(this.time);
					// console.log(e)
					// console.log(this.type)
				}
				this.time = setTimeout(async () => {
					await this.addSaveTaskPrdCol([Object.assign(e, {
						billNo: this.billNo
					})])
				}, 800)
			},

			/**
			 * 完成任务保存临时收货
			 *
			 * @param {string} e
			 * @param {boolean} init 如果为true,则是初始化，count必须为0,serial最后扫码信息
			 * @returns {Promise<void>}
			 */
			async addSaveTaskPrdCol(e = [], init = false, serialNo = '') {
				let result = {}
				try {
					this.btnLoading = true
					let param = null
					param = e.map(v => {
						return {
							id: init ? "" : v.id,
							materialName: v.materialName ?? "",
							materialModel: v.materialModel ?? "",
							materialNo: v.materialNo ?? "",
							unitName: v.unitName ?? "",
							billNo: this.billNo,
							batchNo: v.batchNo ?? "",
							count: init ? 0 : (v.count ?? 0),
							traceBack: v.traceBack ?? [],
							isDelete: v.isDelete,
							standard: v.standard ?? 0,
							currentCount: v.currentCount ?? 0,
							boxNo: v.boxNo ?? "",
							traceCount: v.traceCount,
							orderNum: this.scanIndex,
							serialNo: serialNo
						}
					})
					result = await this.$api.saveTaskAddPrdCol({
						boxList: param
					})
					await this.getSaveTaskPrdColList()
				} catch (e) {
					await this.getSaveTaskPrdColList()
					this.handleMediaPlayer('error')
					// 执行结束后，删除队列中的第一个
					this.queueList.shift()
					// 删除之后，继续执行当前方法
					this.handleRetroactiveScanCode()
				}

				return result
			},

			/** 获取详情数据 */
			async getDataDetail() {
				try {
					let getApi = (this.taskType === 'sorting' && this.type === 'edit') ? "getSortingSaveTaskMaterial" :
						"getPrdTaskDetail"
					let param = (this.taskType === 'sorting' && this.type === 'edit') ? {
						taskBillNo: this.billNo
					} : {
						billNo: this.billNo,
						pda: true
					}
					const res = await this.$api[getApi](param)
					if (!res.res) return
					let list = res.data ?? []
					// 如果不是完成任务，则不需要当前方法去显示列表
					if (this.type === 'edit') {
						// 这里taskList没有值，说明没有创建临时收货列表数据，需要当前方法返回的列表初始化临时收货数据
						if (!this.taskList || !this.taskList.length) {
							await this.addSaveTaskPrdCol(list.map(v => {
								return Object.assign({
									id: "",
									materialNo: "",
									unit: "",
									billNo: "",
									batchNo: "",
									count: 0,
									traceBack: []
								}, v)
							}), true)
							// this.getSaveTaskPrdColList()
						}
					} else {
						this.taskList = list
					}
					this.produceHouseName = res.header.produceHouseName ?? ""
					this.startTime = res.header.startTime ?? ""
					this.endTime = res.header.endTime ?? ""
					this.header = res.header || {}
					this.userCount = this.header.userCount || 0
				} finally {
					this.loading = false
					this.requestStatus = false
					this.handleAllBatchNoCheck()
				}
			},

			/** 获取车间列表 */
			async getDepartment() {
				try {
					let param = this.keyword ? {
						key: this.keyword
					} : {}
					param = Object.assign(param, {
						group: "07",
						pageIndex: this.pickerPageConfig.pageIndex,
						pageSize: this.pickerPageConfig.pageSize,
					})
					let res = await this.$api.getDepartmentList(param)
					if (!res.res) return
					if (this.pickerPageConfig.pageIndex === 0) this.departmentList = []
					if (res.data.length < 20) this.pickerPageConfig.pageEnd = true
					this.departmentList = this.departmentList.concat(res.data ?? [])
					if (this.keyword && !this.departmentList.length) {
						uni.showToast({
							title: "未查到车间信息",
							icon: "none"
						})
					}
					this.$refs.pickerView.updateData({
						treeData: this.departmentList,
						selected: this.produceHouse ? [this.produceHouse] : [],
						selectedIndex: 0
					})
				} finally {
					this.pickerLoading = false
					this.triggered = false
					this.pickerPageConfig.pageLoading = false
					this.$forceUpdate()
				}
			},

			/**
			 * 获取bom物料数据
			 */
			async getBomByKey() {
				try {
					let param = this.keyword ? {
						key: this.keyword
					} : {}
					param = Object.assign(param, {
						pageIndex: this.pickerPageConfig.pageIndex,
						pageSize: this.pickerPageConfig.pageSize,
					})
					if (!this.keyword) {
						this.materialList = []
					} else {
						let api = this.type === "edit" ? "saveGetMaterialByKey" : (this.taskType === 'product' ?
							"getBomByKey" : "getBomSortingList")
						let res = await this.$api[api](param)
						if (!res.res) return
						if (this.pickerPageConfig.pageIndex === 0) this.materialList = []
						if (res.data.length < 20) this.pickerPageConfig.pageEnd = true
						this.materialList = this.materialList.concat(res.data ?? [])
						if (this.keyword && !this.materialList.length) {
							uni.showToast({
								title: "未查到该物料信息",
								icon: "none"
							})
						}
					}
					this.$refs.pickerView.updateData({
						treeData: this.materialList,
						selected: [],
						selectedIndex: 0,
						isMaterial: true,
					})
				} finally {
					this.pickerLoading = false
					this.triggered = false
					this.pickerPageConfig.pageLoading = false
					this.$forceUpdate()
				}
			},

			/**
			 * 获取bom物料数据
			 */
			async getBomSortingList() {
				try {
					let param = this.keyword ? {
						key: this.keyword
					} : {}
					param = Object.assign(param, {
						pageIndex: this.pickerPageConfig.pageIndex,
						pageSize: this.pickerPageConfig.pageSize,
					})
					let res = await this.$api.getBomSortingList(param)
					if (!res.res) return
					if (this.pickerPageConfig.pageIndex === 0) this.materialList = []
					if (res.data.length < 20) this.pickerPageConfig.pageEnd = true
					this.materialList = this.materialList.concat(res.data ?? [])
					if (this.keyword && !this.materialList.length) {
						uni.showToast({
							title: "未查到该物料信息",
							icon: "none"
						})
					}
					this.$refs.pickerView.updateData({
						treeData: this.materialList,
						selected: [],
						selectedIndex: 0,
						isMaterial: true
					})
				} finally {
					this.pickerLoading = false
					this.triggered = false
					this.pickerPageConfig.pageLoading = false
					this.$forceUpdate()
				}
			},

			/**
			 * 增加一条
			 * @param {Object} e
			 * @param {Object} i
			 */
			async handleTemporaryAdd(e, i) {
				let node = JSON.parse(JSON.stringify(e))
				delete node.id
				let param = Object.assign({
					count: 0,

				}, node, {
					traceBack: [],
					billNo: this.billNo,
					isDelete: true,
					currentCount: 0,

				})
				await this.addSaveTaskPrdCol([param])
			},

			/**
			 * 判断是否是成品
			 * 
			 * @param {Object} e
			 */
			handleIsComplete(e) {
				return e.materialNo.startsWith('04') && e.insertUserName === this.userInfo.name
			},

			/**
			 * 追溯扫码
			 * 
			 * @param {Object} e
			 * @param {Object} i
			 */
			handleScanning(e, i) {
				// this.currentBox = null
		
				if (!e.standard) {
					uni.showToast({
						title: "请设置标准数量",
						icon: "none"
					})
					return
				}
				if (Number(e.standard) === e.traceBack.length) {
					uni.showToast({
						title: "已达到标准数量",
						icon: "none"
					})
					return
				}
		
				this.scanIndex = i + (this.current - 1) * this.size
				// console.log(this.size)
				this.$refs.wholePopup.open()
			},

			/**
			 * 添加执行队列
			 * @param {Object} e
			 */
			addQueue(e) {
				// 队列中添加追溯码
				this.queueList.push(e)
				// 如果队列执行中，则返回
				if (this.isExecution) return
				// 如果不是正在执行，则执行方法
				this.handleRetroactiveScanCode(e)
			},

			
			/**
			 * 追溯扫码完成
			 */
			async handleRetroactiveScanCode(e) {
				
				// 如果队列中没有值，isExecution为false, 返回
				if (!this.queueList.length) {
					this.isExecution = false
					return
				} 
				// 如果队列中有值，isExecution为true, 防止快速重复执行该方法
				this.isExecution = true


				// 如果队列中有值，执行第一个,获取追溯码
				let serialNo = this.queueList[0];
				
				// 获取当前数据
				
				this.currentBox = this.taskList[parseInt(this.scanIndex)]
				
				try {
					const res  = await this.$api.addPrdColAndGetPrdCol({
						serialNo: serialNo,
						currentBox: this.currentBox,
						index: this.scanIndex,
						taskBillNo : this.billNo
					})
					
					this.taskList = res.dataList
					this.scanIndex = res.index
					// console.log(this.scanIndex)
					// console.log(res.index)
					if (Number(res.item.standard)  === res.item.traceBack.length) {
						uni.showToast({
							title: "追溯扫码以达到标准数量",
							icon: "none"
						})
					}
					
					// this.currentBox = res.item
					
					// this.currentBox =  this.taskList[this.scanIndex]
					this.handleMediaPlayer('success')	
					// 执行结束后，删除队列中的第一个
					// this.queueList.shift()
					// 本地更新当前用户已扫码数量(避免每次都调用接口获取当前用户已扫数量)
					this.userCount = this.taskList.filter(v => v.insertUserName === this.userInfo.name).reduce((pre,
						cur) => {
						pre += cur.currentCount
						return pre
					}, 0)
					
				} catch (e) {
					this.handleMediaPlayer('warning')
				} finally {
					// 执行结束后，删除队列中的第一个
					this.queueList.shift()
					this.isExecution = false
					if (this.queueList.length >= 1){
						// 删除之后，继续执行当前方法
						this.handleRetroactiveScanCode()
					}
				}
				
			},

			/**
			 * 显示追溯信息
			 * 
			 * @param {Object} e
			 */
			handleTrace(e) {
				let traceBack = e.split("=")
				return traceBack[1] ?? ""
			},

			/**
			 * 删除指定的追溯码
			 * @param {Object} e
			 * @param {Object} i
			 */
			async handleTraceDelete(e, i) {
		
				if (this.btnLoading) return
				
				const self = this
				uni.showModal({
					title: '提示',
					content: '是否确认删除追溯码？',
					success(res) {
						if (res.confirm) {
							e.traceBack.splice(i, 1)
							e.currentCount--
							e.count = e.currentCount
							self.addSaveTaskPrdCol([e]).then(res => {
								self.$forceUpdate()
							})
						}
					}
				})

			},

			/** 审核通过 */
			bindAudioPass() {
				let self = this
				try {
					uni.showModal({
						title: '提示',
						content: '是否确认审核？',
						success(res) {
							if (res.confirm) {
								uni.showLoading({
									mask: true
								})
								self.$api.auditPrdTaskBill({
									billNo: self.billNo
								}).then((res) => {
									if (!res.res) return
									uni.showToast({
										title: "审核完成",
										icon: "none"
									})
									self.getDataDetail()
								})
							}
						}
					})
				} finally {
					uni.hideLoading()
				}
			},

			/** 审核驳回 */
			bindAudioOverruled() {
				let self = this
				try {
					uni.showModal({
						title: '提示',
						content: '是否驳回该任务？',
						success(res) {
							if (res.confirm) {
								uni.showLoading({
									mask: true
								})
								self.$api.auditPrdTaskBill({
									billNo: self.billNo
								}).then((res) => {
									if (!res.res) return
									uni.showToast({
										title: "任务已驳回",
										icon: "none"
									})
									self.getDataDetail()
								})
							}
						}
					})
				} finally {
					uni.hideLoading()
				}
			},

			/** 审核作废 */
			bindAudioInvalidate() {
				let self = this
				try {
					uni.showModal({
						title: '提示',
						content: '是否作废该任务？',
						success(res) {
							if (res.confirm) {
								uni.showLoading({
									mask: true
								})
								self.$api.auditPrdTaskBill({
									billNo: self.billNo
								}).then((res) => {
									if (!res.res) return
									uni.showToast({
										title: "任务已作废",
										icon: "none"
									})
									self.getDataDetail()
								})
							}
						}
					})
				} finally {
					uni.hideLoading()
				}
			},

			/** 审核 */
			async handleWarehousing() {
				let self = this
				this.$refs.as.handleShow({
					actions: [{
						name: '通过',
					}, {
						name: '驳回',
					}, {
						name: '作废',
					}, ],
					success: (res) => {
						switch (res.id) {
							// -1代表取消按钮
							case -1:
								console.log(res)
								break
							case 0:
								this.bindAudioPass()
								break
							case 1:
								this.bindAudioOverruled()
								break
							case 2:
								this.bindAudioInvalidate()
								break
						}
					}
				})

			},

			/**
			 * 生成物料清单
			 */
			async handleGenerateListing() {
				if (!this.taskList.length) {
					uni.showToast({
						title: "请添加生产任务",
						icon: "none"
					})
					return
				}
				if (!this.produceHouse) {
					uni.showToast({
						title: `请选择生产车间`,
						icon: "none"
					})
					return
				}
				let nodeList = JSON.parse(JSON.stringify(this.taskList))
				let isEnd = false
				nodeList.forEach(option => {
					if (!isEnd) {
						if (!option.count || option.count === '0') {
							isEnd = true
							uni.showToast({
								title: `请输入${option.materialName}_${option.materialNo}的数量`,
								icon: "none"
							})
							return
						}
						option.count = Number(option.count ?? 0)
					}
				})
				if (isEnd) return
				let param = {
					dataMap: {
						dataList: nodeList,
						produceHouse: this.produceHouse,
						produceHouseName: this.produceHouseName,
						startTime: this.startTime,
						endTime: this.startTime,
						taskType: this.taskType,
						sort: Number(this.sortList[this.sortIndex]) ?? 0
					}
				}
				this.$navigateTo('/pages/production/bomDetail', {
					type: this.type,
					taskType: this.taskType,
					param: JSON.stringify(param)
				})
			},

			/**
			 * 查看已创建订单列表
			 */
			handleWatchCreatedOrder() {
				this.$navigateTo("/pages/production/orderList", {
					type: this.type,
					billNo: this.header.materialBomBillNo,
					taskBillNo: this.billNo,
					produceHouse: this.header.produceHouseName,
				})
			},

			/** 查看物料清单 */
			handleWatchGenerateListing() {
				this.$navigateTo('/pages/production/bomDetail', {
					type: this.type,
					billNo: this.header.materialBomBillNo,
					taskBillNo: this.billNo,
					produceHouse: this.header.produceHouseName,
				})
			},

			/** 完成任务单 */
			async savePrdTaskToPrdCol() {
				try {
					uni.showLoading({
						mask: true
					})
					let nodeList = this.taskList.filter(option => {
						return (option.count && option.count !== '0')
					})
					if (!nodeList || !nodeList.length) {
						uni.showToast({
							title: '箱子数量不能全部为0',
							icon: 'none'
						})
						return
					}
					if (this.taskType === 'product'){
						if (!this.produceDate || this.produceDate === null){
							uni.showToast({
								title: '生产日期必填',
								icon: 'none'
							})
							return
						}
					}
					nodeList.forEach(option => {
						if (option.hasOwnProperty('count')) {
							option.count = Number(option.count)
						}
					})
					// 如果是完成任务，不需要传boxList
					let params = this.type === "edit" ? {
						billNo: this.billNo,
						supplierBatchNo: this.supplierBatchNo,
						produceDate: this.produceDate
					} : {
						boxList: nodeList,
						billNo: this.billNo,
						produceDate: this.produceDate
					}
					const self = this
					uni.showModal({
						title: '提示',
						content: '是否完成任务？',
						success(res) {
							if (res.confirm) {
								self.$api.savePrdTaskToPrdCol(params).then(res => {
									if (!res.res) return
									uni.hideLoading()
									uni.showToast({
										title: '任务已完成',
										icon: 'none'
									})
									setTimeout(() => {
										uni.navigateBack()
									}, 500)
								})
							}

						}
					})
				} finally {
					uni.hideLoading()
				}
			},

			/**
			 * 删除物料
			 * @param {Object} e
			 */
			handleDelete(i) {
				const self = this
				uni.showModal({
					title: '提示',
					content: '是否删除物料？',
					success(res) {
						if (res.confirm) {
							self.taskList.splice(i, 1)
							uni.showToast({
								title: '生产任务删除成功',
								icon: 'none'
							})
						}
					}
				})
			},

			/** 选择 */
			handleChooseDepartment(e) {
				if (this.billNo && this.type === 'edit' && e === 'department') return
				this.keyword = null
				// 当前操作的类型
				this.currentType = e
				this.onRefresh()
			},

			/**
			 * 选择排序等级
			 */
			bindPickerChange(e) {
				this.sortIndex = e.detail.value
			},

			/**
			 * 点击搜索按钮
			 * @param {Object} e
			 */
			handleSearch(e) {
				if (this.currentType === 'material' && /^\d+$/.test(e) && e.length < 5) {
					uni.showToast({
						title: "请输入大于5位的物料编码",
						icon: "none"
					})
					return
				}
				this.pickerPageConfig.pageEnd = false
				this.keyword = e
				this.pickerPageConfig = {
					pageIndex: 0,
					pageSize: 20,
					pageEnd: false,
					pageLoading: true
				}
				if (this.currentType === 'material') {
					this.getBomByKey()
				} else {
					this.getDepartment()
				}
			},
			/**
			 * 下拉
			 */
			onRefresh() {
				this.pickerPageConfig = {
					pageIndex: 0,
					pageSize: 20,
					pageEnd: false,
					pageLoading: true
				}
				this.triggered = true
				if (this.currentType === 'material') {
					this.getBomByKey()
				} else {
					this.getDepartment()
				}
			},
			/**
			 * 滑动到底部
			 */
			handleScrolltolower() {
				if (this.pickerPageConfig.pageEnd || this.pickerPageConfig.pageLoading) return
				this.pickerPageConfig.pageLoading = true
				this.pickerPageConfig.pageIndex++
				if (this.currentType === 'material') {
					this.getBomByKey()
				} else {
					this.getDepartment()
				}
			},
			async onchange(e) {
				this.bat = false
				if (this.type === 'edit' && this.currentType === 'material') {
					let node = JSON.parse(JSON.stringify(e))
					let param = {
						count: 1,
						materialModel: node.materialModel,
						materialName: node.materialName,
						materialNo: node.materialNo,
						unitName: node.unitName,
						traceBack: [],
						billNo: this.billNo,
						isDelete: true
					}
					await this.addSaveTaskPrdCol([param])
					return
				}
				if (this.currentType === 'material') {
					this.bomChange(e)
				} else {
					this.departmentChange(e)
				}
			},
			bomChange(e) {
				let childMaterialNo = e.childList?.length ? e.childList[0].childMaterialNo : ''
				let node = this.taskList.find(option => {
					return option.materialNo === e.materialNo && option.childList[0].childMaterialNo ===
						childMaterialNo
				})
				if (node) {
					uni.showToast({
						title: '已添加该物料任务',
						icon: 'none'
					})
					return
				}
				this.taskList.push(Object.assign(e, {
					count: "",
				}))
			},
			departmentChange(e) {
				this.produceHouse = e.fNumber
				this.produceHouseName = e.fName
			},

			/**
			 * 输入批次
			 * @param {Object} type
			 */
			bindInputBatchNo(type) {
				this.inputType = type
				if (this.inputType === 'supplier') {
					this.supplierBatchNoTem = this.supplierBatchNo
				}
				this.batchPopup.title = this.inputType === 'batch' ? '填写批次' : (this.inputType === 'supplier' ? '填写供应商批次' :
					'跳转至')
				this.batchPopup.confirm = this.inputType === 'batch' ? '一键应用所有批次' : '确定'
				this.$refs.batchPopup.open('center')
			},
			checkBatch(){
				if (this.batchNo.startsWith("BN")){
					if (this.header.bnBom){
						return '';
					} else{
						return 'BN';
					}
				} else{//如果批次不是BN
					if (this.header.notBn){
						return '';
					} else{
						return 'notBN';
					}
				}
			},
			/**
			 * 一件应用所有批次
			 */
			async bindApplyBatchNo() {
				let self = this
				if (this.inputType === 'batch') {
					if (!self.batchNo) {
						uni.showToast({
							title: "请输入批次",
							icon: "none"
						})
						return
					}
					//判断批号
					let check = this.checkBatch()
					console.log(!check)
					if (check){//如果返回的有值说明有问题
					let title = ''
						if(check === 'BN'){
							title = '领料和补料没有BN,是否确认收货是BN'
						} else{
							title = '领料和补料有BN,是否确认收货是没有BN'
						}
						uni.showModal({
							title: '提示',
							content: title,
							success(res) {
								if (res.confirm) {
									self.taskList.forEach(option => {
										option.batchNo = self.batchNo
									})
									 self.addSaveTaskPrdCol(self.taskList)
									self.$forceUpdate()
									self.bat = true
									uni.showToast({
										title: "批次修改成功",
										icon: "none"
									})
								}
							}
						})
					} else{
						this.taskList.forEach(option => {
							option.batchNo = self.batchNo
						})
						 await this.addSaveTaskPrdCol(this.taskList)
						this.$forceUpdate()
						this.bat = true
						uni.showToast({
							title: "批次修改成功",
							icon: "none"
						})
					}
					
				} else if (this.inputType === 'supplier') {
					this.supplierBatchNo = this.supplierBatchNoTem
					this.supplierBatchNoTem = ""
				} else {
					if (!/^\d+$/.test(this.currentPage)) {
						uni.showToast({
							title: "请输入页数",
							icon: "none"
						})
						return
					}
					this.current = Number(this.currentPage)
					this.hanldeMathPage()
					this.currentPage = null
				}
				this.$refs.batchPopup.close()
			},

			/**
			 * 
			 */
			handlePageTo() {

			}
		}
	}
</script>
<style lang="scss" scoped>
	@import "../../static/css/common";

	.batchPopup-panel {
		background-color: #fff;
		padding: 20px;
		border-radius: 10px;

		.batchPopup-panel-top {
			position: relative;

			.batchPopup-panel-top-title {
				text-align: center;
				font-size: 14px;
			}
		}

		.batchPopup-panel-content {
			margin: 20px 0;

			.batchPopup-panel-content-input {
				height: 50px;
				border: 1px solid $border-bc;
				border-radius: 10px;
				display: flex;
				align-items: center;
				padding: 0 15px;

				input {
					width: 100%;
					text-align: center;
				}
			}
		}

		.batchPopup-panel-footer {
			.batchPopup-panel-footer-btn {
				width: 70vw;
				font-size: 14px;
			}
		}
	}

	.panel .panel_content .panel_content_row .panel_content_row_item {
		max-width: 50%;
	}

	.panel .panel_content .panel_content_row .panel_content_row_item .padding-r {
		padding-right: 5px;
	}

	.uni-data-tree {
		flex: 1;
		position: relative;
		font-size: 14px;
	}

	.error-text {
		color: #DD524D;
	}

	.input-value {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		flex-wrap: nowrap;
		font-size: 14px;
		/* line-height: 35px; */
		padding: 0 10px;
		padding-right: 5px;
		overflow: hidden;
		height: 35px;
		/* #ifdef APP-NVUE */
		/* #endif */
		box-sizing: border-box;
	}

	.input-value-border {
		border: 1px solid #e5e5e5;
		border-radius: 5px;
	}

	.selected-area {
		flex: 1;
		overflow: hidden;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
	}

	.load-more {
		/* #ifndef APP-NVUE */
		margin-right: auto;
		/* #endif */
		/* #ifdef APP-NVUE */
		width: 40px;
		/* #endif */
	}

	.selected-list {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		flex-wrap: nowrap;
		/* padding: 0 5px; */
	}

	.selected-item {
		flex-direction: row;
		/* padding: 0 1px; */
		/* #ifndef APP-NVUE */
		white-space: nowrap;
		/* #endif */
	}

	.text-color {
		color: #333;
	}

	.placeholder {
		color: grey;
		font-size: 12px;
	}

	.input-split-line {
		opacity: .5;
	}

	.arrow-area {
		position: relative;
		width: 20px;
		/* #ifndef APP-NVUE */
		margin-bottom: 5px;
		margin-left: auto;
		display: flex;
		/* #endif */
		justify-content: center;
		transform: rotate(-45deg);
		transform-origin: center;
	}

	.input-arrow {
		width: 7px;
		height: 7px;
		border-left: 1px solid #999;
		border-bottom: 1px solid #999;
	}

	.uni-data-tree-cover {
		position: fixed;
		left: 0;
		top: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(0, 0, 0, .4);
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		z-index: 100;
	}

	.uni-data-tree-dialog {
		position: fixed;
		left: 0;
		top: 20%;
		right: 0;
		bottom: 0;
		background-color: #FFFFFF;
		border-top-left-radius: 10px;
		border-top-right-radius: 10px;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		z-index: 102;
		overflow: hidden;
		/* #ifdef APP-NVUE */
		width: 750rpx;
		/* #endif */
		font-size: 14px;
		color: #606266;
	}

	.dialog-caption {
		position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		/* border-bottom: 1px solid #f0f0f0; */
	}

	.title-area {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		align-items: center;
		/* #ifndef APP-NVUE */
		margin: auto;
		/* #endif */
		padding: 0 10px;
	}

	.dialog-title {
		/* font-weight: bold; */
		line-height: 44px;
	}

	.dialog-close {
		position: absolute;
		top: 0;
		right: 0;
		bottom: 0;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		padding: 0 15px;
	}

	.dialog-close-plus {
		width: 16px;
		height: 2px;
		background-color: #666;
		border-radius: 2px;
		transform: rotate(45deg);
	}

	.dialog-close-rotate {
		position: absolute;
		transform: rotate(-45deg);
	}

	.picker-view {
		flex: 1;
		overflow: hidden;
	}

	.icon-clear {
		display: flex;
		align-items: center;
	}

	/* #ifdef H5 */
	@media all and (min-width: 768px) {
		.uni-data-tree-cover {
			background-color: transparent;
		}

		.uni-data-tree-dialog {
			position: absolute;
			top: 55px;
			height: auto;
			min-height: 400px;
			max-height: 50vh;
			background-color: #fff;
			border: 1px solid #EBEEF5;
			box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
			border-radius: 4px;
			overflow: unset;
		}

		.dialog-caption {
			display: none;
		}

		.icon-clear {
			/* margin-right: 5px; */
		}
	}

	/* #endif */

	/* picker 弹出层通用的指示小三角, todo：扩展至上下左右方向定位 */
	/* #ifndef APP-NVUE */
	.uni-popper__arrow,
	.uni-popper__arrow::after {
		position: absolute;
		display: block;
		width: 0;
		height: 0;
		border-color: transparent;
		border-style: solid;
		border-width: 6px;
	}

	.uni-popper__arrow {
		filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
		top: -6px;
		left: 10%;
		margin-right: 3px;
		border-top-width: 0;
		border-bottom-color: #EBEEF5;
	}

	.uni-popper__arrow::after {
		content: " ";
		top: 1px;
		margin-left: -6px;
		border-top-width: 0;
		border-bottom-color: #fff;
	}

	/* #endif */

	.list-pagination {
		position: -webkit-sticky;
		/* Safari 和 iOS 版 Chrome 需要加上 -webkit- 前缀 */
		position: sticky;
		/* #ifdef APP-PLUS */
		top: 0px;
		/* #endif */
		/* #ifndef APP-PLUS */
		top: 44px;
		/* #endif */
		/* 距离父元素顶部的距离为0 */
		z-index: 1;

		.list-pagination-inner {
			box-sizing: border-box;
			background-color: #f8f8f8;
			
			.item-sticky {
				background-color: #fff;
				position: relative;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				padding: 12px 15px;
				padding-left: 15px;
				flex: 1;
				overflow: hidden;
				
				.title {
					font-size: 14px;
					color: #3b4144;
					overflow: hidden;
				}

				.extra {
					color: #999;
					font-size: 12px;
					
				}
			}

			.pagination {
				padding: 8px 10px;
			}
		}
	}

	.btn_icon {
		margin-right: 8px;
	}
</style>